import Vue from 'vue'
import Vuex from 'vuex'
/* import CN from '../lang/cn'
import TW from '../lang/tw' */
// import common from "@/common/common";
// import apiAjax from '../ajax/apiAjax';
Vue.use(Vuex)
//TW ： 繁体中文  CN ： 简体中文
/* let userStatus = false
if (Vue.ls.get(common.tokenKey)) {
    userStatus = true;
} */
import Land from "@/page/land/views/01";
export default new Vuex.Store({
    state: {
        routeList: []
    },
    mutations: {
        // 挂载路由
        initDynamicRoutes(state ,params) {
            const currentRoutes = params.$router.options.routes;
            state.routeList.forEach((item) => {
                let obj = {};
                obj.path = item.page_route.replace(/^land\//, "");
                obj.component = Land;
                obj.path_id = item.id
                currentRoutes[2].children.push(obj);
            });
            params.$router.addRoutes(currentRoutes);
        },
    },
    actions: {
        // 获取路由列表
        async GET_Route_List({ state, commit }, params) {
            const { data, code } = await params.$api.getRouteList();
            if (!code) {
                state.routeList = data;
                commit('initDynamicRoutes' , params)
            }
        }
    },
    getters: {


    },
    modules: {}
})






























































































